<?php

namespace app\index\controller;

use app\common\controller\HomeBase;
use think\Db;

class Alists extends HomeBase {

    
    public function index() {

        $order_by = 'publish_time desc';
        
        $sort = input('param.sort');
        if($sort){
            $sort_arr = explode('-', $sort);
            if(in_array($sort_arr[1],array('asc','desc')) && in_array($sort_arr[0], array('publish_time','reading'))){
                $order_by = $sort_arr[0].' '.$sort_arr[1];
            }
        }
        
        $data = Db::name('Article')->cache(3600)->field('id,title,introduction,reading,publish_time')->order($order_by)->paginate(15);
        
        
        //获取日周月排行
        $ranking = getColumnRanking2(16);
        
        return $this->fetch('',['data'=>$data,'page'=>$data->render(),'ranking'=>$ranking,'sort'=>isset($sort_arr) ? $sort_arr[0] : '','title'=>'电影资讯','keywords'=>'电影资讯,电影最新动态,最热新闻']);
    }
    
}
